import { RouteRecordRaw } from "vue-router";

// Main
const Main = import("@/layout/main.vue");
/**
 * mate的定义
 *  isTabbar?: 页面中是否带tabbar  (其原理就是页面都是layout中固定还是父级页面)    default: false
 *  icon?: 当需要被用到图标时，即渲染相关的icon        default: null
 *  roles?: Array<string> 该路由是roles中具有的权限  defaultL: ["*"]
 *  isHidden?: 是否在需要显示的地方隐藏   default: true
 *  keepAlive?: 是否缓存组件  default: false
 */

// 静态路由
const constants: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/main'
    },
    {
        path: '/main',
        name: 'Main',
        component: Main,
        // redirect: {name: 'Home'},
        redirect: {path: "/main/index"},
        // meta: {
        //     isTabbar: true,
        //     icon: 'home-o',
        //     keepAlive: true,
        //     roles: ['admin', 'finnace'],
        //     title: '首页'
        // },
        children: [
            {
                path: 'index',
                component: import("@/views/home/index.vue"),
                name: 'Home',
                meta: {
                    isTabbar: true,
                    roles: ['admin'],
                    keepAlive: true,
                    icon: 'home-o',
                    title: '首页'
                }
            },
            {
                path: 'indexB',
                component: import("@/views/home/index.vue"),
                name: 'HomeB',
                meta: {
                    isTabbar: true,
                    title: '测试',
                    roles: ['a', 'b']
                }
            }
        ]
    },
    {
        path: '/search',
        name: 'MainB',
        component: Main,
        // redirect: {name: 'Home'},
        // meta: {
        //     isTabbar: true,
        //     icon: 'search',
        //     keepAlive: true,
        //     title: '搜索'
        // },
        children: [
            {
                path: "index",
                name: 'SearchIndex',
                component: () => import("@/views/search/index.vue"),
                meta: {
                    keepAlive: true,
                    isTabbar: true,
                    icon: 'search',
                    title: "搜索"
                }
            }
        ]
    },
    {
        path: '/mainC',
        name: 'MainC',
        component: Main,
        // redirect: {name: 'Home'},
        meta: {
            isTabbar: true,
            icon: 'search',
            keepAlive: true,
            title: '搜索',
            roles: ['aaa']
        }
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import("@/views/login/index.vue"),
    }
];

export default constants;